package gfx.tiles;

import java.awt.image.BufferedImage;
import java.util.ArrayList;

/**
 * 
 * Represents a tile which has an image and can be solid.
 * Tiles created can be added to the tiles ArrayList. 
 * 
 * @author lueko.voss
 *
 */
public class Tile {

    private TileGraphics tileGraphic;
    private int color;
    private int state;
    public static final int START_SIZE = 32;
    public static int size = 32;
    
    public static ArrayList<Tile> tiles = new ArrayList<Tile>();
    
    /*
     * Viable states of a tile.
     */
    public static final int AIR = 0;
    public static final int SOLID = 1;
    public static final int WATER = 2;
    public static final int LAVA = 3;
    
    public static final Tile err = new Tile(TileGraphics.err, 0x0, AIR, false);
    
    /**
     * @param tileGraphic Image of the tile.
     * @param color Color which represents a tile.
     * @param state Sets the state of a tile.
     */
    public Tile(TileGraphics tileGraphic, int color, int state) {
        this(tileGraphic, color, state, true);
    }
    
    /**
     * @param tileGraphic Image of the tile.
     * @param color Color which represents a tile.
     * @param solid Sets whether a tile is solid.
     * @param add Sets whether a tile should be added to the tiles ArrayList.
     */
    public Tile(TileGraphics tileGraphic, int color, int state, boolean add) {
        this.tileGraphic = tileGraphic;
        this.color = color;
        this.state = state;
        if (add) tiles.add(this);
    }
    
    /**
     * @return Returns the image of the tile.
     */
    public BufferedImage getTileImage() {
        return tileGraphic.image;
    }
    
    /**
     * @return Returns the representing tile color.
     */
    public int getColor() {
    	return color;
    }
    
    /**
     * @return Returns the state of the tile.
     */
    public int state() {
        return state;
    }
    
}
